package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.CommissionService;
import com.yixun.qfbao.apidto.GetSettlementPageReqDto;
import com.yixun.qfbao.apidto.GetSettlementPageResDto;
import com.yixun.qfbao.apidto.GetSettlementRecordReqDto;
import com.yixun.qfbao.apidto.GetSettlementRecordResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetSettlementPageReqVo;
import com.yixun.qfbao.vo.GetSettlementRecordReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description
 * @Date 2017/12/9
 * @Author sangtao
 * @Computer Administrator
 */
@Service("getSettlementPageHander")
public class GetSettlementPageHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(GetSettlementPageHander.class);
    @Autowired
    private CommissionService commissionService;

    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        BaseResponseDTO<GetSettlementPageResDto> res = new BaseResponseDTO<GetSettlementPageResDto>();
        GetSettlementPageResDto resDto = new GetSettlementPageResDto();
        GetSettlementPageReqVo reqVo = (GetSettlementPageReqVo)reqDto;
        GetSettlementPageReqDto getSettlementPageReqDto = reqVo.getParams();
        try {
            resDto = commissionService.getSettlementPage(getSettlementPageReqDto);
        } catch (Exception e) {
            logger.error("GetSettlementPageHander error: {}", e);
            res.setResult(ResultEnum.FAIL.getNo());
            res.setErrorMsg("获取机构佣金详情失败");
        }
        res.setResult(resDto.getResult());
        res.setResData(resDto);
        return res;
    }
}
